
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="ntModalLabel" type="{$type}">{$title}</h4>
        <input type="hidden" id="pro_id" value="{$pro_id}">
    </div>
    <div class="modal-body">
            <div class="row clearfix">
                    <div class="col-md-12 column">
                        <div class="alert alert-dismissable alert-info">
                            <button type="button" class="close">×</button>
                            <p></p>
                        </div>
                    </div>
                </div>
        <div class="row clearfix">
            <div class="col-md-12 column">
                <table class="table table-striped ntTable">
                    <tbody>
                        <tr>
                            <td>{:lang("the_role_of_product")}<span class="required"></span></td>
                            <td colspan="3">
                                <select class="form-control" id="prochar">
                                    {if isset($prochar)}
                                        {foreach $prochar as $k=>$v}
                                            <option value="{$v.id}"> {$v.feature_zh}</option>
                                        {/foreach}
                                    {/if}
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>产品分类<span class="required"></span></td>
                            <td>
                                <div class="input-group" style="width:100%">
                                    <div class="input-group">
                                        <select  class="form-control" name="" id="procat" style="width: 150px;">
                                            <option selected >{:lang("please_select_a_product_category")}</option>
                                            {volist name='procat' id='vo'}
                                            <option value="{$vo.id}">{$vo.level|default=0|str_repeat='&emsp;',###*2}{$vo.content}</option>
                                            {/volist}
                                        </select>
                                        
                                    </div>
                                    
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>{:lang("product_accessory_name")}<span class="required"></span></td>
                            <td>
                                <div class="input-group" style="width:100%">
                                    <div class="input-group">
                                            <div class="input-group-btn">
                                            <select  class="form-control" name="" id="prolist" style="width: 150px;">
                                                <option >{:lang("please_select_a_product_name")}</option>
                                                    {if isset($itempro)}
                                                        <option value="{$itempro.id}" selected>{$itempro.content}</option>
                                                    {/if}
                                                </select>
                                            </div>
                                            <input type="text" class="form-control" id="searchText" placeholder="{:lang("enter_product_name_/_number")}">
                                            <div class="input-group-btn">
                                                <button type="button" class="btn btn-primary search">
                                                    <span class="glyphicon glyphicon-search" > </span> {:lang('search')}
                                                </button>
                                            </div>
                                        
                                    </div>
                                    
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>{:lang("accessories_role")}<span class="required"></span></td>
    						<td>
    							<select class="form-control" id='itemchar'>
                                    {if isset($itemprochar)}
                                        <option value="{$itemprochar.id}" selected>{$itemprochar.content}</option>
                                    {/if}
    							</select>
    						</td>
    					</tr>
                        <tr>
                            <td>{:lang("accessories_quantity")}<span class="required"></span></td>
                            <td><input type="number" id="item_qty" class="form-control text-right" value="{if isset($qty)}{$qty}{/if}"></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <input type="hidden" id="item_id" value="{if isset($item_id)}{$item_id}{/if}">
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>{:lang('cancel')}</button>
        <button type="button" class="btn btn-primary save" style="padding-left:24px;padding-right:24px"><span class="glyphicon glyphicon-ok"></span>{:lang('confirm')}</button>
    </div>
    <script type="text/javascript">
        $('#procat').change(function(){
            // alert($('#procat option:selected').val())
            if($('#ntModalLabel').attr('type') == 'edit'){
                var url = '/admin/product/proAddNewJump_itemEdit'
            }else{
                var url = '/admin/product/proAddNewJump_itemAdd'
            }
            $.ajax({
                // url: '/admin/product/proAddNewJump_itemAjax?request=pro',
                url: url,
                type: 'post',
                data: {cat_id:$('#procat option:selected').val(),pro_id:$('#pro_id').val(),request:'pro'},
                dataType: 'json',
                success: function (res) {
                    res = JSON.parse(res)
                    if(res.code == 2000){
                        $('#prolist').empty();
                        var pro_html = "<option value='0'>"+langcon.please_select+"</option>";
                        for (var i = 0;i < res.data.length; i++) {
                            pro_html += "<option value='"+res.data[i].id+"'>"+res.data[i].content+"</option>";
                        }
                        $('#prolist').append(pro_html);
                    }else{
                        alert(res.msg);
                    }
                }
            })
        });

        $('#prolist').change(function(){
            if($('#ntModalLabel').attr('type') == 'edit'){
                var url = '/admin/product/proAddNewJump_itemEdit'
            }else{
                var url = '/admin/product/proAddNewJump_itemAdd'
            }
            // alert($('#procat option:selected').val())
            $.ajax({
                // url: '/admin/product/proAddNewJump_itemAjax?request=prochar',
                url:url,
                type: 'post',
                data: {id:$('#prolist option:selected').val(),request:'prochar'},
                dataType: 'json',
                success: function (res) {
                    res = JSON.parse(res)
                    if(res.code == 2000){
                        $('#itemchar').empty();
                        var prochar_html = "<option value='0'>"+langcon.please_select+"产品角色</option>";
                        for (var i = 0;i < res.data.length; i++) {
                            prochar_html += "<option value='"+res.data[i].id+"'>"+res.data[i].content+"</option>";
                        }
                        $('#itemchar').append(prochar_html);
                    }else{
                        alert(res.msg);
                    }
                }
            })
        });

        $('.save').click(function(){
            if($('#ntModalLabel').attr('type') == 'edit'){
                var url = '/admin/product/proAddNewJump_itemEdit?request=update'
            }else{
                var url = '/admin/product/proAddNewJump_itemAdd?request=insert'
            }
            $.ajax({
                url: url,
                type: 'post',
                data: {
                        qty:$('#item_qty').val(),
                        pro_id:$('#pro_id').val(),
                        prochar_id:$('#prochar option:selected').val(),
                        pro_id2item:$('#prolist option:selected').val(),
                        prochar_id2item:$('#itemchar option:selected').val(),
                        id:$('#item_id').val()
                    },
                success: function (data) {
                    data = JSON.parse(data)
                    if (data.status != 1) {
                        //toastr.warning(data.msg);
                        change_mes_type('.modal-body .alert',data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*'+data.msg+'<br>')
                    } else {
                        change_mes_type('.alert',data.status)
                        $('.alert').show()
                        $('#pro2item_editModal').modal('hide')
                        $('.alert p').html('*'+data.msg+'<br>')
                        //toastr.info(data.msg)
                    }
                }
            })
        });

        $('.search').click(function(){

            if($('#ntModalLabel').attr('type') == 'edit'){
                var url = '/admin/product/proAddNewJump_itemEdit'
            }else{
                var url = '/admin/product/proAddNewJump_itemAdd'
            }
            $.ajax({
                // url: '/admin/product/proAddNewJump_itemAjax?request=search',
                url: url,
                type: 'post',
                data: {searchText:$('#searchText').val(),pro_id:$('#pro_id').val(),request:'searchText'},
                dataType: 'json',
                success: function (res) {
                    res = JSON.parse(res)
                    console.log(res)
                    if(res.code == 2000){ 
                        $('#prolist').empty();
                        var prochar_html = "<option value='0'>"+langcon.please_select+"</option>";
                        for (var i = 0;i < res.data.length; i++) {
                            prochar_html += "<option value='"+res.data[i].id+"'>"+res.data[i].content+"</option>";
                        }
                         $('#prolist').append(prochar_html);
                     }else{
                        alert(res.msg);
                    } 
                }
            })
        });
    </script>